import request from '@/utils/http'

export interface PostJiTaiBaoBiao_gongXuResult {
  detaildatas: {
    machineDocumentId: string
    machineName: string
    machineNo: number
    machineTypeName: string
    tsid: number
    shiftName: string
    teamSet: string
    efcRun: number
    speedAvg1: number
    yarnLength: number
    theoreticalYarnWeight: number
    actualYarnWeight: number
    power: number
    begin: string
    end: string
    materialName: string
    theoreticalPowerPerWeight: number
    actualPowerPerWeight: number
    maxSpeed: number
  }[]
  classifydatas: {
    machineName: string
    machineNo: number
    machineTypeName: string
    efcRun: number
    speedAvg1: number
    yarnLength: number
    theoreticalYarnWeight: number
    actualYarnWeight: number
    power: number
    theoreticalPowerPerWeight: any
    actualPowerPerWeight: number
    maxSpeed: number
  }[]
  groupdata: {
    efcRun: number
    speedAvg1: number
    yarnLength: number
    theoreticalYarnWeight: number
    actualYarnWeight: number
    breakWeight: number
    isHasEnergy: boolean
    maxSpeed: number
    power: number
    actualPowerPerWeight: number
    // ??
    s11003: any
    s11004: any
    stopTimes: any
  }
}

export interface PostWuLiaoBaoBiao_gongXuResult {
  detaildata: {
    processDispatchQueueId: any
    materialName: string
    materialId: string
    machineDocumentId: string
    machineName: string
    machineNo: number
    machineTypeName: string
    tsid: number
    shiftDate: any
    shiftName: string
    teamSet: string
    shiftNum: any
    begin: string
    end: string
    yarnLength: number
    theoreticalYarnWeight: number
    actualYarnWeight: number
    efcRun: number
    speedAvg1: number
    coe: any
    weightPerLength: number
    power: number
    shiftPowerOns: number
    runtimes: number
    theoreticalPowerPerWeight: number
    actualPowerPerWeight: number
    maxSpeed: number
    id: any
    groupNo: number
    efcMachine: any
    r23261: any
  }[]
  classifydata: {
    materialName: string
    efcRun: number
    speedAvg1: number
    yarnLength: number
    theoreticalYarnWeight: number
    actualYarnWeight: number
    power: number
    theoreticalPowerPerWeight: number
    actualPowerPerWeight: number
    maxSpeed: number
    efcMachine: any
  }[]
  groupdata: {
    efcRun: number
    speedAvg1: number
    yarnLength: number
    theoreticalYarnWeight: number
    actualYarnWeight: number
    breakWeight: number
    isHasEnergy: boolean
    maxSpeed: number
    power: number
    actualPowerPerWeight: number
    efcMachine: any
    // ??
    s11003: any
    s11004: any
    stopTimes: any
  }
}

// 根据班次、机台，查询班报
export function postJiTaiAndBaoBiao(data) {
  return request.request({
    url: '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine',
    method: 'post',
    data
  })
}

// 数据报表-织机
export function postZhiJiBaoBiao(data) {
  return request.request({
    url: '/api/v3.1/business/loom-machine-shift-report/loom-report-by-tsid-machine',
    method: 'post',
    data
  })
}

// 数据报表-络筒
export function postLuoTongBaoBiao(data) {
  return request.request({
    url: '/api/v3.1/business/lt-third-machine-shift-repord/loom-report-by-tsid-machine',
    method: 'post',
    data
  })
}

// 根据班次、物料，查询班报
export function postWuLiaoAndBaoBiao(data) {
  return request.request({
    url: '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material',
    method: 'post',
    data
  })
}

// 新增或修改配置记录
export function postXingZengPeiZhi(data) {
  return request.request({
    url: '/api/v3.1/business/setting-utils/create-or-update',
    method: 'post',
    data
  })
}

// 查找系统配置
export function postHuoQuPeiZhi(data) {
  return request.request({
    url: '/api/v3.1/business/setting-utils/setting-info',
    method: 'post',
    data
  })
}

/**
 * 根据班次范围综合报表查询
 */
export function postBanCiAndZongHeBaoBiao(data) {
  return request.request({
    url: '/api/v3.1/business/composite-report/composite-report-by-tsid',
    method: 'post',
    data
  })
}
/**
 * 根据班次、机台查询络筒基础报表
 */
export function postBanCiJiTaiBaoBiaLuoTong(data) {
  return request.request({
    url: '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine-lt',
    method: 'post',
    data
  })
}
/**
 * 根据班次、机台查询气流纺基础报表
 */
export function postBanCiJiTaiBaoBiaQiLiuFang(data) {
  return request.request({
    url: '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine-qlf',
    method: 'post',
    data
  })
}
/**
 * 根据班次、物料查询络筒基础报表
 */
export function postBanCiWuLiaoBaoBiaLuoTong(data) {
  return request.request({
    url: '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material-lt',
    method: 'post',
    data
  })
}
/**
 * 根据班次、物料查询气流纺基础报表
 */
export function postBanCiWuLiaoBaoBiaQiLiuFang(data) {
  return request.request({
    url: '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material-qlf',
    method: 'post',
    data
  })
}

/**
 * 根据班次、物料查询各工序基础报表
 */
export function postWuLiaoBaoBiao_gongXu(gongXu, data) {
  let url = ''
  if (gongXu === '细纱') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material-xs'
  } else if (gongXu === '梳棉') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material-sm'
  } else if (gongXu === '末并') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material-mb'
  } else if (gongXu === '预并') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material-yb'
  } else if (gongXu === '条卷') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material-tbj'
  } else if (gongXu === '精梳') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material-js'
  } else if (gongXu === '粗纱') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material-cs'
  } else if (gongXu === '织机') {
    url = '/api/v3.1/business/machine-shift-report-zj/machine-shift-report-zj-by-material'
  } else if (gongXu === '气流纺') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material-qlf'
  } else if (gongXu === '倍捻') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material-bn'
  } else if (gongXu === '络筒') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-material-lt'
  }

  return request.request<PostWuLiaoBaoBiao_gongXuResult>({
    url: url,
    method: 'post',
    data
  })
}

/**
 * 根据班次、机台查询各工序基础报表
 */
export function postJiTaiBaoBiao_gongXu(gongXu: string, data: Recordable) {
  let url = ''
  if (gongXu === '细纱') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine-xs'
  } else if (gongXu === '梳棉') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine-sm'
  } else if (gongXu === '末并') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine-mb'
  } else if (gongXu === '预并') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine-yb'
  } else if (gongXu === '条卷') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine-tbj'
  } else if (gongXu === '精梳') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine-js'
  } else if (gongXu === '粗纱') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine-cs'
  } else if (gongXu === '织机') {
    url = '/api/v3.1/business/machine-shift-report-zj/machine-shift-report-zj-by-machine'
  } else if (gongXu === '气流纺') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine-qlf'
  } else if (gongXu === '倍捻') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine-bn'
  } else if (gongXu === '络筒') {
    url =
      '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-machine-lt'
  }
  return request.request<PostJiTaiBaoBiao_gongXuResult>({
    url: url,
    method: 'post',
    data
  })
}

/**
 * 更新月盘存的系数
 */
export function putGengXinPanCunXiShu(data) {
  return request.request({
    url: '/api/v3.1/business/inventory-month-report/coefficient',
    method: 'put',
    data
  })
}

/**
 * 指定月份，查询梳棉月度盘存记录
 */
export function getYueDuPanCunJiLu_SM(month) {
  return request.request({
    url: '/api/v3.1/business/inventory-month-report/inventory-month-report-sm?month=' + month,
    method: 'get'
  })
}

/**
 * 录入上次盘存的桶数和重量
 */
export function putLuRuPanCunTonShuAndZhongLiang(data) {
  return request.request({
    url: '/api/v3.1/business/inventory-month-report/inventory-month-report',
    method: 'put',
    data
  })
}

/**
 * 指定月份，查询末并月度盘存记录
 */
export function getYueDuPanCunJiLu_MB(month) {
  return request.request({
    url: '/api/v3.1/business/inventory-month-report/inventory-month-report-mb?month=' + month,
    method: 'get'
  })
}

/**
 * 细纱报表-实际产能，指定月份，查询实际产能
 */
export function getShiJiCanDeng_XS(month) {
  return request.request({
    url: '/api/v3.1/business/machine-ht-xs/actual-production-ststistics?month=' + month,
    method: 'get'
  })
}

/**
 * 指定日期，查询月报日期信息
 */
export function getYueBaoXinXinChaXun(month) {
  return request.request({
    url: '/api/v3.1/business/month-set-record/month-set-record-by-day?month=' + month,
    method: 'get'
  })
}

/**
 * 数据报表-机台班报，指定班次，查询细纱机机台班报
 */
export function getJiTaiBanBao_xs(data) {
  return request.request({
    url:
      '/api/v3.1/business/machine-ht-xs/machine-ht-xs-by-tsid-machine?TsIdStart=' +
      data.TsIdStart +
      '&TsIdEnd=' +
      data.TsIdEnd,
    method: 'get'
  })
}

/**
 * 数据报表-品种分类日报，指定班次，查询细纱机品种分类日报
 */
export function getPingZhongRiBao_xs(data) {
  return request.request({
    url:
      '/api/v3.1/business/machine-ht-xs/machine-ht-xs-by-tsid-material?TsIdStart=' +
      data.TsIdStart +
      '&TsIdEnd=' +
      data.TsIdEnd,
    method: 'get'
  })
}

/**
 * 数据报表-品种分类月报，指定班次，查询细纱机品种分类报表
 */
export function getPingZhongYueBao_xs(data) {
  return request.request({
    url:
      '/api/v3.1/business/machine-ht-xs/machine-ht-xs-by-material?TsIdStart=' +
      data.TsIdStart +
      '&TsIdEnd=' +
      data.TsIdEnd,
    method: 'get'
  })
}

/**
 * 查询区域设置
 */
export function getQuYuSheZhi() {
  return request.request({
    url: '/api/v3.1/business/area-machine-asso',
    method: 'get'
  })
}

/**
 * 新增区域设置
 */
export function postQuYuSheZhi(data) {
  return request.request({
    url: '/api/v3.1/business/area-machine-asso',
    method: 'post',
    data
  })
}
/**
 * 修改区域设置
 */
export function putQuYuSheZhi(data) {
  return request.request({
    url: '/api/v3.1/business/area-machine-asso',
    method: 'put',
    data
  })
}
/**
 * 删除区域设置
 */
export function deleteQuYuSheZhi(id) {
  return request.request({
    url: '/api/v3.1/business/area-machine-asso/' + id,
    method: 'delete'
  })
}

/**
 * 数据报表-区域统计月报，指定班次，查询细纱机区域统计报表
 */
export function getQuYuTongJiBaoBiao(data) {
  return request.request({
    url:
      '/api/v3.1/business/machine-ht-xs/machine-ht-xs-by-area?TsIdStart=' +
      data.TsIdStart +
      '&TsIdEnd=' +
      data.TsIdEnd,
    method: 'get'
  })
}
/**
 * 数据报表-设备异常报表
 */
export function getYiChangShuJuBaoBiao(data) {
  return request.request({
    url:
      '/api/v3.1/business/machine-ht-xs/machine-alarm-asnc?TsIdStart=' +
      data.TsIdStart +
      '&TsIdEnd=' +
      data.TsIdEnd,
    method: 'get'
  })
}

/**
 * 打包机数据，指定班次，设备id，查询络筒/平台/垛位品种记录
 */
export function getDaBaoJiPingZhongJiLu(data) {
  return request.request({
    url:
      '/api/v3.1/business/da-sheng-dbj/db-material-ds/' +
      data.id +
      '?TsIdStart=' +
      data.TsIdStart +
      '&TsIdEnd=' +
      data.TsIdEnd,
    method: 'get'
  })
}

/**
 * 打包机数据-品种成跺
 */
export function getDaBaoJiPingZhongChengDuo(data) {
  return request.request({
    url:
      '/api/v3.1/business/da-sheng-dbj/cheng-duo-lT?TsIdStart=' +
      data.TsIdStart +
      '&TsIdEnd=' +
      data.TsIdEnd,
    method: 'get'
  })
}

/**
 * 打包机数据-络筒上纱、络筒卸纱个数、筒纱单纱、工位视觉、包装
 */
export function getPackageMachineList(data, apiStr) {
  return request.request({
    url: `/api/v3.1/business/da-sheng-dbj/${apiStr}-lT?TsIdStart=${data.TsIdStart}&TsIdEnd=${data.TsIdEnd}`,
    method: 'get'
  })
}

/**
 * 打包机数据-打包记录
 */
export function getDaBaoJiDaBao(data) {
  return request.request({
    url: '/api/v3.1/business/da-sheng-dbj/da-bao-lT',
    method: 'post',
    data
  })
}

/**
 * 指定开始时间、结束时间、机台，查询峰平谷尖电区间的效率
 */
export function postShiJianQuYuXiaoLv_FPGJ(data) {
  return request.request({
    url: '/api/v3.1/business/energy-period-report/energy-period-run-efc-statistics',
    method: 'post',
    data
  })
}
/**
 * 指定开始时间、结束时间、机台，查询峰平谷尖电区间的效率趋势图
 */
export function postXiaoLvQuShiTu_FPGJ(data) {
  return request.request({
    url: '/api/v3.1/business/energy-period-report/energy-period-run-efc-tendency',
    method: 'post',
    data
  })
}

/**
 * 指指定机台、开始时间、结束时间，查询停车明细列表
 */
export function postTingCheMingXiLieBiao_FPGJ(data) {
  return request.request({
    url: '/api/v3.1/business/machine-run-log-daily-report/machine-run-logs',
    method: 'post',
    data
  })
}

/**
 * 指定开始时间、结束时间、机台，查询清梳联峰平谷尖电区间的效率
 */
export function postQingShuLianShiJianQuYuXiaoLv_FPGJ(data) {
  return request.request({
    url: '/api/v3.1/business/energy-period-report/energy-period-run-efc-statistics-qsl',
    method: 'post',
    data
  })
}

/**
 * 指定开始时间、结束时间、机台，查询清梳联峰平谷尖电区间的效率
 */
export function postQingShuLianShiJianQuYuXiaoLv_sm(data) {
  return request.request({
    url: '/api/v3.1/business/energy-period-report/energy-period-run-efc-statistics-sm',
    method: 'post',
    data
  })
}
/**
 * 指定开始时间、结束时间、机台，查询清梳联峰平谷尖电区间的效率趋势图
 */
export function postQingShuLianXiaoLvQuShiTu_FPGJ(data) {
  return request.request({
    url: '/api/v3.1/business/energy-period-report/energy-period-run-efc-tendency-qsl',
    method: 'post',
    data
  })
}

/**
 * 指定开始时间、结束时间、机台，查询梳棉峰平谷尖电区间的效率趋势图
 */
export function postQingShuLianXiaoLvQuShiTu_sm(data) {
  return request.request({
    url: '/api/v3.1/business/energy-period-report/energy-period-run-efc-tendency-sm',
    method: 'post',
    data
  })
}

/**
 * 指定开始时间、结束时间，查询锭带断记录
 */
export function getDingDaiDuanData(data) {
  return request.request({
    url:
      '/api/v3.1/business/position-tap-break-record/position-tap-break-record?Start=' +
      data.Start +
      '&End=' +
      data.End,
    method: 'get'
  })
}

/**
 * 指定开始时间、结束时间，查询落纱留头率统计记录
 */
export function getLuoShaLiuTouLvTongJiJiLu(data) {
  return request.request({
    url:
      '/api/v3.1/business/doffing-analysis-appservice/doff-intact-rate-statistics?Start=' +
      data.Start +
      '&End=' +
      data.End,
    method: 'get'
  })
}

/**
 * 指定开始班次、结束班次，查询停台报表
 */
export function getTingTaiBaoBiao(data) {
  return request.request({
    url:
      '/api/v3.1/business/machine-run-log-edit/machine-park-report?CraftNodeId=' +
      data.CraftNodeId +
      '&TsidStart=' +
      data.TsidStart +
      '&TsidEnd=' +
      data.TsidEnd,
    method: 'get'
  })
}
/**
 * 批量编辑产量效率中的停止时间与原因
 */
export function putPiLiangChanLiangXiaoLv(data) {
  return request.request({
    url: '/api/v3.1/business/shift-stop-edit/shift-stop-edit',
    method: 'put',
    data
  })
}

/**
 * 获取产量效率
 */
export function postPiLiangChanLiangXiaoLv(data) {
  return request.request({
    url: '/api/v3.1/business/shift-stop-edit/shift-stop',
    method: 'post',
    data
  })
}

/**
 * 获取络筒产量效率(带统计)
 */
export function postPiLiangChanLiangXiaoLv_lt(data) {
  return request.request({
    url: '/api/v3.1/business/shift-stop-edit/shift-stop-lt-statistic',
    method: 'post',
    data
  })
}
/**
 * 获取产量效率
 */
export function postPiLiangChanLiangXiaoLv_qf(data) {
  return request.request({
    url: '/api/v3.1/business/shift-stop-edit/shift-stop-fore',
    method: 'post',
    data
  })
}
